package io.github.biezhi.factory.simpleFactory;

/**
 * 简单工厂模式定义了一个用于创建对象的静态方法，根据传入的参数决定创建哪种产品对象。
 */
interface Shape {
    void draw();
}

class Circle implements Shape {
    @Override
    public void draw() {
        System.out.println("Inside Circle::draw() method.");
    }
}

class Squere implements Shape {
    @Override
    public void draw() {
        System.out.println("Inside Squere::draw() method.");
    }
}

public class SimpleFactory {
    public static Shape getShape(String shapeType) {
        if (shapeType == null) {
            return null;
        }
        if (shapeType.equalsIgnoreCase("CIRCLE")) {
            return new Circle();
        } else if (shapeType.equalsIgnoreCase("SQUERE")) {
            return new Squere();
        }
        return null;
    }

    public static void main(String[] args) {
        Shape circle = SimpleFactory.getShape("CIRCLE");
        circle.draw();

        Shape squere = SimpleFactory.getShape("SQUERE");
        squere.draw();
    }
}


